package com.yfp.goods.service.impl;

import com.yfp.goods.domain.GoodsNutritive;
import com.yfp.goods.mapper.GoodsNutritiveMapper;
import com.yfp.goods.service.GoodsNutritiveService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品营养表(GoodsNutritive)表服务实现类
 *
 * 
 * @since 2023-12-20 22:22:55
 */
@Service("goodsNutritiveService")
public class GoodsNutritiveServiceImpl implements GoodsNutritiveService {
    @Resource
    private GoodsNutritiveMapper goodsNutritiveMapper;



    /**
     * 按商品id查询
     *
     * @param goodsId 货物id
     * @return {@link List}<{@link GoodsNutritive}>
     */
    @Override
    public List<GoodsNutritive> queryByGoodsId(String goodsId) {
        GoodsNutritive goodsNutritive = new GoodsNutritive();
        goodsNutritive.setGoodsId(goodsId);
        goodsNutritive.setIsDelete(false);
        return this.goodsNutritiveMapper.queryAll(goodsNutritive);
    }

    /**
     * 新增数据
     *
     * @param goodsNutritive 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsNutritive insert(GoodsNutritive goodsNutritive) {
        this.goodsNutritiveMapper.insert(goodsNutritive);
        return goodsNutritive;
    }

    /**
     * 修改数据
     *
     * @param goodsNutritive 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsNutritive update(GoodsNutritive goodsNutritive) {
        this.goodsNutritiveMapper.update(goodsNutritive);
        return goodsNutritive;
    }

    /**
     * 插入或更新批
     *
     * @param goodsNutritive 商品营养品
     * @return int
     */
    @Override
    public int insertOrUpdateBatch(List<GoodsNutritive> goodsNutritive) {
       return this.goodsNutritiveMapper.insertOrUpdateBatch(goodsNutritive);
    }

}
